<template>
  <div class="header">
    <div class="flex_row_between">
      <span @click="handleBack">{{ title }}</span>
      <el-switch
        v-model="isDark"
        active-text="🌙"
        inactive-text="☀️"
        @change="handleToggleTheme"
      ></el-switch>
    </div>
  </div>
</template>

<script setup>
import { useDark, useToggle } from '@vueuse/core'
const props = defineProps({
  title: {
    type: String,
    default: 'CL文档地址集合',
  },
})
const emits = defineEmits(['toggleTheme'])
const isDark = useDark()
const toggleDark = useToggle(isDark)

const handleBack = () => {
  window.history.back()
}

const handleToggleTheme = (val) => {
  toggleDark(val)
  emits('toggleTheme', val)
}
</script>

<style lang="scss" scoped>
.header {
  padding: 20px;
  font-weight: bold;
  font-size: 28px;
  box-shadow: 0px 10px 10px 0px rgba(154, 153, 154, 0.15);
  background-color: #fff;
  span {
    cursor: pointer;
  }
}
</style>
